# 1 基础数据类型的类型注解
import json
import random

var1: int = 1
var2: bool = True
var3: float = 5.6
var4: str = 'success'


# 2 类对象的类型注解
class Student:
    pass


stu: Student = Student()

# 3 基础容器的类型注解
my_list1: list = [1, 2, 3]
my_tuple1: tuple = (1, 2, 3)
my_set: set = {6, 7, 8}
my_dict: dict = {'name': 'Jagochan', 'score': 100}

# 详细注解
my_list2: list[int] = [1, 2, 3]
my_tuple: tuple[int, str, bool] = (666, '666', True)
my_set2: set[int] = {6, 7, 8}
my_dict2: dict[str, int] = {'name': 'Jagochan', 'score': 100}
print(my_dict2['name'])

# 注释中进行类型注解
var_one = random.randint(1, 19)  # type: int
var_two = json.loads('{"name": "Jagochan"}')  # type: dict[str, str]


def f():
    return 9


var_three = f()  # type: int
